/* eslint valid-jsdoc: "off" */

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1736474761775_1429';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    port: 3306,
    username: 'root',
    password: 'wangqidong123',
    database: 'node_book',
    define: {
      timestamps: true,
      underscored: false, // 是否讲属性转为下划线
      freezeTableName: true, // 强执修改数据表名为model名，不采用默认的复数形式
      // 不想要 createdAt
      createdAt: false,
      updatedAt: false,
      // 想要 updatedAt 但是希望名称叫做 updateTimestamp
      //   updatedAt: 'updateTimestamp',
    },
    timezone: '+8:00',
    dialectOptions: {
      dateStrings: true,
      typeCast(field, next) {
        if (field.type === 'DATETIME') {
          return field.string();
        }
        return next();
      },
    },
  };

  return {
    ...config,
    ...userConfig,
  };
};
